#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: splice03_dml.py 
@version:
@time: 2022/02/16 
"""
from TapClientCaseData.ColumnGenerateData.dynamic.splice01_mysql.splice04_sole_dml import *

__all__ = [
    'DML_MYSQL_STRING_CATEGORY_INSERT', 'DML_MYSQL_STRING_CATEGORY_UPDATE',
    'DML_MYSQL_NUMERIC_CATEGORY_INSERT', 'DML_MYSQL_NUMERIC_CATEGORY_UPDATE',
    'DML_MYSQL_DATE_TIME_CATEGORY_INSERT', 'DML_MYSQL_DATE_TIME_CATEGORY_UPDATE',
    'DML_MYSQL_DATE_TIME_CATEGORY_INSERT57', 'DML_MYSQL_DATE_TIME_CATEGORY_UPDATE57',

    'DML_MYSQL_ALL_INSERT', 'DML_MYSQL_ALL_UPDATE',
    'DML_MYSQL_ALL_INSERT57', 'DML_MYSQL_ALL_UPDATE57'
]


# --- CATEGORY ---

def generate_category(args):
    """
    return ( )
    :param args:
    :return:
    """
    tmp = []
    for i in args:
        tmp.append(str(i))
    return f"{', '.join(tmp)}"


def CATEGORY_INSERT(LIST):
    insert0 = []
    insert1 = []
    for ONE in LIST:
        insert0.append(ONE.get('COLUMNS'))
        insert1.append(ONE.get('INSERT'))
    return [generate_category(insert0), generate_category(insert1)]


def CATEGORY_UPDATE(LIST):
    TMP = {}
    for ONE in LIST:
        TMP.update(ONE.get('UPDATE'))
    return TMP


# ---------- DML ----------

# ---- STRING ----
DML_MYSQL_STRING_CATEGORY = [
    DML_MYSQL_CHAR,
    DML_MYSQL_VARCHAR,
    DML_MYSQL_BINARY,
    DML_MYSQL_VARBINARY,
    DML_MYSQL_TINYBLOB,
    DML_MYSQL_TINYTEXT,
    DML_MYSQL_BLOB,
    DML_MYSQL_TEXT,
    DML_MYSQL_MEDIUMBLOB,
    DML_MYSQL_MEDIUMTEXT,
    DML_MYSQL_LONGBLOB,
    DML_MYSQL_LONGTEXT,
    DML_MYSQL_ENUM,
    # DML_MYSQL_SET set can't use common
]
DML_MYSQL_STRING_CATEGORY_INSERT = CATEGORY_INSERT(DML_MYSQL_STRING_CATEGORY)
DML_MYSQL_STRING_CATEGORY_UPDATE = CATEGORY_UPDATE(DML_MYSQL_STRING_CATEGORY)

# ---- NUMERIC ----
DML_MYSQL_NUMERIC_CATEGORY = [
    DML_MYSQL_BIT,
    DML_MYSQL_TINYINT,
    DML_MYSQL_TINYINT_UNSIGNED,
    DML_MYSQL_BOOL,
    DML_MYSQL_BOOLEAN,
    DML_MYSQL_SMALLINT,
    DML_MYSQL_SMALLINT_UNSIGNED,
    DML_MYSQL_MEDIUMINT,
    DML_MYSQL_MEDIUMINT_UNSIGNED,
    DML_MYSQL_INT,
    DML_MYSQL_INT_UNSIGNED,
    DML_MYSQL_BIGINT,
    DML_MYSQL_BIGINT_UNSIGNED,
    DML_MYSQL_DECIMAL,
    DML_MYSQL_DECIMAL_UNSIGNED,
    DML_MYSQL_FLOAT,
    DML_MYSQL_FLOAT_UNSIGNED,
    DML_MYSQL_DOUBLE,
    DML_MYSQL_DOUBLE_UNSIGNED
]
DML_MYSQL_NUMERIC_CATEGORY_INSERT = CATEGORY_INSERT(DML_MYSQL_NUMERIC_CATEGORY)
DML_MYSQL_NUMERIC_CATEGORY_UPDATE = CATEGORY_UPDATE(DML_MYSQL_NUMERIC_CATEGORY)

# ---- DATE/TIME ----
DML_MYSQL_DATE_TIME_CATEGORY = [
    DML_MYSQL_DATE,
    DML_MYSQL_DATETIME,
    DML_MYSQL_TIMESTAMP,
    DML_MYSQL_TIME,
    DML_MYSQL_YEAR,
]
DML_MYSQL_DATE_TIME_CATEGORY_INSERT = CATEGORY_INSERT(DML_MYSQL_DATE_TIME_CATEGORY)
DML_MYSQL_DATE_TIME_CATEGORY_UPDATE = CATEGORY_UPDATE(DML_MYSQL_DATE_TIME_CATEGORY)

DML_MYSQL_DATE_TIME_CATEGORY57 = [
    DML_MYSQL_DATE,
    DML_MYSQL_DATETIME57,
    DML_MYSQL_TIMESTAMP57,
    DML_MYSQL_TIME57,
    DML_MYSQL_YEAR,
]
DML_MYSQL_DATE_TIME_CATEGORY_INSERT57 = CATEGORY_INSERT(DML_MYSQL_DATE_TIME_CATEGORY57)
DML_MYSQL_DATE_TIME_CATEGORY_UPDATE57 = CATEGORY_UPDATE(DML_MYSQL_DATE_TIME_CATEGORY57)

# ---- ALL ----
DML_MYSQL_ALL = DML_MYSQL_STRING_CATEGORY + DML_MYSQL_NUMERIC_CATEGORY + DML_MYSQL_DATE_TIME_CATEGORY
DML_MYSQL_ALL57 = DML_MYSQL_STRING_CATEGORY + DML_MYSQL_NUMERIC_CATEGORY + DML_MYSQL_DATE_TIME_CATEGORY57

DML_MYSQL_ALL_INSERT = CATEGORY_INSERT(DML_MYSQL_ALL)
DML_MYSQL_ALL_UPDATE = CATEGORY_UPDATE(DML_MYSQL_ALL)

DML_MYSQL_ALL_INSERT57 = CATEGORY_INSERT(DML_MYSQL_ALL57)
DML_MYSQL_ALL_UPDATE57 = CATEGORY_UPDATE(DML_MYSQL_ALL57)
